package stream;

import org.junit.Test;

import java.util.stream.IntStream;

public class IntStreamTest {

    /**
     * of创建流
     */
    @Test
    public void of() {
        IntStream inputStream = IntStream.of(25,231,2,5,2,3434,121);
    }

    /**
     * 前闭后开
     */
    @Test
    public void range() {
        IntStream.range(1, 10).forEach(System.out::println);
    }

    /**
     * 前闭后闭
     */
    @Test
    public void rangeClosed() {
        IntStream.rangeClosed(1, 10).forEach(System.out::println);
    }

    /**
     * IntStream和LongStream特有的方法，Stream不具有
     */
    @Test
    public void sum() {
        System.out.println(IntStream.rangeClosed(1, 10).sum());
    }
}
